recObj = audiorecorder(48000,16,1);
disp('Start speaking......')
recordblocking(recObj, 5);       % 设置录音时间
disp('End of Recording.')         % 显示录音结束
play(recObj);                  % 获取录音属性并播放
myRecording = getaudiodata(recObj);   % 绘制录音数据波形
subplot 211;
plot(myRecording);                  % 绘制语音信号
Fs=8000;
n=length(myRecording);
hw=fft(myRecording,n);%对录制信号进行傅里叶变换
y_mag=abs(hw);
f=Fs*(0:n-1)/n;
subplot 212;
plot(f,y_mag);
xlabel('频率(hz)');title('原始信号频谱');
xlim([0 4000]);
filename = 'recoding.wav';
audiowrite(filename,myRecording,48000);
